const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    dateString: "",
    spot: ['2022/9/21', '2022/9/24', '2022/9/30', '2022-10-15', '2022/11/8'],
    show:false,
    defaultDate:'',
    dataList:[]
  },
  onReady: function() {
		if (!app.login()) {
			return;
		}
	},
  dateChange(e) {
    this.setData({
      dateString: e.detail.dateString
    });
    this.getMySchedule();
  },
  toToday() {
    let year = new Date().getFullYear(),
      month = new Date().getMonth() + 1,
      day = new Date().getDate();
    this.setData({
      year,
      day,
      month
    })
  },
  onLoad: function() {
      this.getMyScheduleSpot();
      this.getMySchedule();
  },
  getMyScheduleSpot(){
    var that = this;
		http.httpPost(config.getMyScheduleSpot, {
		}, function(e) {
			if (e.code == 1) {
				that.setData({
          spot: e.data
				});
			} 
      console.log(that.data.spot);
		});
  },
  getMySchedule(){
    var that = this;
    var dateString = that.data.dateString;
		http.httpPost(config.getMySchedule, {
			dtime:dateString
		}, function(e) {
			if (e.code == 1) {
        // console.log(e);
        if(e.data.length==0){
          wx.showToast({
            title: e.msg,
            icon: 'none',
            duration: 2000,
            mask: true
          });
        }
				that.setData({
          'dataList': e.data
				});
			} 
		
		});
  }

})